% *********************************************
% DRCC demo
% *********************************************

clear all;

load('COIL20.mat');
nClass = length(unique(y));

% Normalize each data vector to have L2-norm equal to 1  
X = NormalizeFea(X);

% *********************************************
% Baseline 1: Kmeans clustering in the original space
% *********************************************
rand('twister', 5489);
label = litekmeans(X, nClass, 'Replicates', 20);
MIhat = MutualInfo(y, label);
disp(['Clustering in the original space. MIhat: ',num2str(MIhat)]);
% Clustering in the original space. MIhat: 0.7386

% *********************************************
% Baseline 2: Kmeans clustering in the NMF subspace
% *********************************************
% NMF learning 
options = [];
options.maxIter = 100;
options.alpha = 0; %when alpha = 0, GNMF boils down to the ordinary NMF.
rand('twister', 5489);
[U, V] = GNMF(X', nClass, [], options); %'

% Clustering in the NMF subspace
rand('twister', 5489);
label = litekmeans(V, nClass, 'Replicates', 20);
MIhat = MutualInfo(y, label);
disp(['Clustering in the NMF subspace. MIhat: ',num2str(MIhat)]);
%Clustering in the NMF subspace. MIhat:  0.74361

% *********************************************
% Baseline 2: Kmeans clustering in the GNMF subspace
% *********************************************
% GNMF learning
options = [];
options.WeightMode = 'Binary';  
W = constructW(X,options);
options.maxIter = 100;
options.alpha = 100;
rand('twister', 5489);
[U, V] = GNMF(X', nClass, W, options); %'
% clear U V W;

% Clustering in the GNMF subspace
rand('twister', 5489);
label = litekmeans(V, nClass, 'Replicates', 20);
MIhat = MutualInfo(y, label);
disp(['Clustering in the GNMF subspace. MIhat: ',num2str(MIhat)]);
%Clustering in the GNMF subspace. MIhat: 0.87599


% *********************************************
% Baseline 4: Kmeans clustering in the DRCC subspace
% *********************************************
% DRCC learning
options = [];
options.WeightMode = 'Binary';
smpW = constructW(X, options);
feaW = constructW(X', options);
options.maxIter = [];
options.rowLamda = 100;
options.colLamda = options.rowLamda;
rand('twister', 5489);
[U, S, V] = DRCC(X', nClass, nClass, feaW, smpW, options); %'
% clear U S V feaW smpW;

% Clustering in the DRCC subspace
rand('twister', 5489);
label = litekmeans(V, nClass, 'Replicates', 20);
MIhat = MutualInfo(y, label);
disp(['Clustering in the DRCC subspace. MIhat: ',num2str(MIhat)]);
%Clustering in the GNMF subspace. MIhat: 0.8836

